<?php
/**
 * Svick a Fast Simple Smart PHP FrameWork
 * Author: Tommy 863758705@qq.com
 * Link: http://svick.tomener.com/
 * Since: 2022
 */

namespace Svick\Http\Client;

/**
 * @method static Request asJson()
 * @method static Request asForm()
 * @method static Request attach(string $name, string|resource $contents, string|null $filename = null, array $headers = [])
 *
 * @method static Request withHeaders(array $headers)
 * @method static Request withRedirect(bool|array $redirect)
 * @method static Request withStream(bool $boolean)
 * @method static Request withVerify(bool|string $verify = false)
 * @method static Request withBasicAuth(string $username, string $password)
 * @method static Request withDigestAuth(string $username, string $password)
 * @method static Request withUA(string $ua)
 * @method static Request withToken(string $token, string $type = 'Bearer')
 * @method static Request withCookies(array $cookies, string $domain)
 * @method static Request withProxy(string|array $proxy)
 * @method static Request withVersion(string $version)
 * @method static Request withOptions(array $options)
 *
 * @method static Request async(bool $async = true)
 * @method static Request co(bool $concurrent = true)
 * @method static Request delay(int $seconds)
 * @method static Request timeout(int $seconds)
 * @method static Request concurrency(int $num)
 *
 * @method static Response get(string $url, array $query = [])
 * @method static Response post(string $url, array $data = [])
 * @method static Response patch(string $url, array $data = [])
 * @method static Response put(string $url, array $data = [])
 * @method static Response delete(string $url, array $data = [])
 * @method static Response head(string $url, array $data = [])
 * @method static Response options(string $url, array $data = [])
 *
 * @method static Request concurrent(array $promise)
 * @method static Request pool($promise)
 *
 */
class Http
{
    /**
     * @var Request
     */
    protected $request;

    public function __construct()
    {
        $this->request = new Request();
    }

    public function __call($name, $arguments)
    {
        return call_user_func_array([$this->request, $name], $arguments);
    }

    public static function __callStatic($name, $arguments)
    {
        return call_user_func_array([new static(), $name], $arguments);
    }
}
